{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "94a92ee0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "fd095364",
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import date"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6a6b83e4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(9999, 12, 31)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "date.max"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "c9d17ce4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2021, 9, 13)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "date.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "693af6dc",
   "metadata": {},
   "outputs": [],
   "source": [
    "d=date.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "e0c12f8d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2021"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d.year"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "bf51b378",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "13"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "date.today().day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3b9612a5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "015fe79d",
   "metadata": {},
   "source": [
    "------------------------------------------------------------------------ "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "87b6a769",
   "metadata": {},
   "source": [
    "# range()的方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "52316101",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# range 决定了 循环的次数\n",
    "# range 本质上是计数的一个类型  odds = [1,3,5,7,9] \n",
    "\n",
    "for i in range(5):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "6c5799a9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[5, 6, 7, 8, 9]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(5,10))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "51aa00c8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[3, 6, 9]"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(3,10,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "886762b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[-10, -40, -70]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(-10,-100,-30))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bc18d310",
   "metadata": {},
   "source": [
    "--------------------------------------------------------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5ccec350",
   "metadata": {},
   "source": [
    "# random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "72a2e7ff",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'random' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-40-7e9eeb6dc0ff>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mrandom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrange\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m: name 'random' is not defined"
     ]
    }
   ],
   "source": [
    "random.range()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5baee302",
   "metadata": {},
   "source": [
    "-------------------------------------------------------"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "48b92d56",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = ['xiaoming','lihua','xiaohongzhou']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "33f3d432",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "xiaoming---000000\n",
      "lihua---000001\n",
      "xiaohongzhou---000002\n"
     ]
    }
   ],
   "source": [
    "# enumerate 枚举 产生 steps 的位置索引值（index）\n",
    "# for i in names: 取到了 names 中的值（values）\n",
    "\n",
    "\n",
    "for i,k in enumerate(names):\n",
    "     print(k+'---00000'+str(i))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "69e384cc",
   "metadata": {},
   "source": [
    "-----------------------------------------------------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "db432eba",
   "metadata": {},
   "source": [
    "## 练习1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "75622457",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "this minute seems a little odd\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "\n",
    "odds = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"this minute seems a little odd\")\n",
    "else: \n",
    "    print(\"not an odd minute\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c7eda7c5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
